package com.sg.fileService.service.impl;

import org.springframework.stereotype.Service;

import com.sg.common.exception.BaseBusinessException;
import com.sg.fileService.common.FileUploadException;
import com.sg.fileService.entity.FileTypeConfig;
import com.sg.fileService.util.MP3AVEncoder;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class AudioUploadServiceImpl extends BaseFileUploadServiceImpl {
	@Override
	protected void doEncoder(String sourcePath, FileTypeConfig fileConfig)  throws BaseBusinessException{
		//如果需要进行视频转换
		if(fileConfig.getEncodeAble()){
			MP3AVEncoder encoder = new MP3AVEncoder();
			try{
				encoder.encoderAudio(sourcePath);
			}catch(Exception e){
				log.error("-->音频:{}处理失败:{}",sourcePath,e.getMessage());
				throw new BaseBusinessException("文件转码失败"); 
			}
		}
		
	}

}
